package main

/*
	参考 Hystrix 实现一个滑动窗口计数器。
*/
import (
	"fmt"
	"github.com/afex/hystrix-go/hystrix"
	"io/ioutil"
	"net/http"
)

func main() {
	datatest := []byte{}
	_ = hystrix.Do("my_command", func() error {
		res, err := http.Get("https://fanyi.baidu.com/")
		if err != nil {
			return err
		}

		defer res.Body.Close()

		data, err := ioutil.ReadAll(res.Body)
		if err != nil {
			return err
		}
		datatest = data
		return nil
	}, func(err error) error {
		fmt.Println("任务失败")
		return nil
	})
}
